package com.cskaoyan.service;

import com.cskaoyan.bean.Log;
import com.cskaoyan.bean.LogExample;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.mapper.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 创建日期: 2022/05/06 20:33
 *
 * @author 孙豪骏
 */
@Service
public class LogService {
    @Autowired
    LogMapper logMapper;

    public void insert(Log log) {
        logMapper.insert(log);
    }

    public List<Log> queryLogList(BaseParam baseParam, String name) {
        LogExample logExample = new LogExample();
        logExample.setOrderByClause(baseParam.getSort() + " " + baseParam.getOrder());

        LogExample.Criteria criteria =logExample.createCriteria();
        if (name != null && !"".equals(name)) {
            criteria.andAdminLike("%" + name + "%");
        }

        List<Log> logs = logMapper.selectByExample(logExample);
        return logs;

    }
}